<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="group9.UserStory" %>
<%@ page import="group9.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<!-- Claudio Herreros, Dylan James, Tyler Berg -->

	<%
		User user = (User)session.getAttribute("User");
	
		if (user == null){
			response.sendRedirect("login.jsp");
		}
	
		//User user = (User) req.getSession().getAttribute("User");
		UserStory userstory = (UserStory)session.getAttribute("UserStory");
		
		if (userstory == null)
		{
			response.sendRedirect("MyUserStories.jsp");
		}
	%>
	<head>
		<script type="text/javascript">
			function checkFields(form)
			{
				if (form.title.value == "")
				{
					alert("Please enter a title.");
					form.title.focus();
					return false;
				}

				if (form.description.value == "")
				{
					alert("Please enter a description.");
					form.description.focus();
					return false;
				}
		
			return true;
		}
		</script>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<link rel="stylesheet" type="text/css" href="styles.css" title="Style 1" />
		<title>Edit User Story</title>
	</head>
	<body>
		<h1>Edit User Story</h1>
		<a href="/SignOut" class="Signout">SignOut</a></span>
		<br />
		<hr />
		<br />

		<form name="addstory" action="/editUserStory" method="post" onsubmit="return checkFields(this);">
			<span  class="BoxLabel">Title:</span>
			<br />
			<input name="title" type="text" value="<%=userstory.getTitle() %>"/>
			<br />
			<br />
			<span  class="BoxLabel">Description:</span>
			<br />
			<textarea name="description" rows="10" cols="40" ><%=userstory.getDescription() %></textarea>
			<br />
			<br />
			<span  class="BoxLabel">Test Notes:</span>
			<br />
			<textarea name="testnotes" rows="10" cols="40" ><%=userstory.getTestNotes() %></textarea>
			<br />
			<input type="submit" value="Submit"/>
			<input type="button"value="Cancel" onclick="location.href='MyUserStories.jsp'"></td>
		</form>
		<br/>
 		<hr/>
    	<a href="MyUserStories.jsp">Back!</a>
	</body>
</html>